#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1010;
const ll inf = 0x3f3f3f3f3f3f3f3f;

int cnt = 1,h[N],d[N],now[N],S,T,t = N,n,m;
ll maxflow;
struct edge{int v;ll w;int nxt;}e[N<<2];
void link(int x,int y,ll w){e[++cnt] = (edge){y,w,h[x]};h[x] = cnt;e[++cnt] = (edge){x,0,h[y]};h[y] = cnt;}

bool bfs(){
	memset(d,0,sizeof(d)); now[S] = h[S]; d[S] = 1; queue<int> q; q.push(S);
	while(q.size()){
		int x = q.front(); q.pop();
		for(int i = h[x],y;i;i = e[i].nxt)
			if(!d[y = e[i].v] && e[i].w){
				d[y] = d[x] + 1; now[y] = h[y]; q.push(y); if(y == T) return 1;
			}
	}return 0;
}

ll dfs(int x,ll flow){
	if(x == T) return flow; ll res = flow;
	for(int i = now[x],y;i && res;i = e[i].nxt){
		now[x] = i;
		if(d[y = e[i].v] == d[x] + 1 && e[i].w){
			int k = dfs(y,min(e[i].w,res));
			if(!k) d[y] = 0; res -= k; e[i].w -= k; e[i ^ 1].w += k;
		}
	}return flow - res;
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in;
	for(int i = 1,u,v;i <= m;i++){
		u = in,v = in;ll w = in * t + 1; link(u,v,w);
	}
	S = 1;T = n;ll flow = 0;
	while(bfs()) while(flow = dfs(S,inf)) maxflow += flow;
	printf("%lld %lld\n",maxflow / t,maxflow % t);
	return 0;
}

